#!/usr/bin/env python
#
# Copyright 2009 http://www.yuntien.com
# Licensed under the Apache License, Version 2.0

import wsgiref.handlers

from google.appengine.ext import webapp

from ytblog.controller import *
import ytblog.config

ytblog_url = ytblog.config.CONFIG['url_blog']+'/'

application = webapp.WSGIApplication([
  ('^'+'/',                                       BlogListController),
  ('^'+ytblog_url+r'(\d+)/$',                     BlogDisplayController),
  ('^'+ytblog_url+r'add/$',                       BlogAddController),
  ('^'+ytblog_url+r'edit/(\d+)/$',                BlogEditController),
  ('^'+ytblog_url+r'delete/(\d+)/$',              BlogDeleteController),
  ('^'+ytblog_url+r'comment/(\d+)/$',             BlogCommentController),
  ('^'+ytblog_url+r'comment/delete/(\d+)/$',      BlogCommentDeleteController),
  ('^'+ytblog_url+r'promote/(\d+)/$',             BlogPromoteController),
  ('^'+ytblog_url+r'my/$',                        BlogMyListController),
  ('^'+ytblog_url+r'all/$',                       BlogAllListController),
  ('^'+ytblog_url+r'rss/$',                       BlogRSSController),
  ('^'+ytblog_url,                                BlogListController),
  ('^'+ytblog.config.CONFIG['url_blog'],          BlogListController),
  
  #admin test usage
  ('^'+ytblog_url+r'admin/$',                     BlogAdminController)
], debug=ytblog.config.DEBUG)

def main():
  wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__':
  main()
